home *** CD-ROM | disk | FTP | other *** search
- // list.d
- //
- // generate a symbol list and number each symbol
- //
- // Copyright (c) David G. Shipman 7/94
- //
-
- BOOL bType,
- bDesc;
-
- HANDLE hSel,
- hEnt,
- hSymList;
-
- STRING sDQLExpression,
- sLayer,
- sSymbolDesc,
- sSymbolType,
- sSymbol;
-
- NUMBER nCount,
- nSymCount,
- nTextHeight,
- nDrawingScale,
- nSize,
- nHorizJust,
- nVertJust,
- nLeft,
- nTop,
- nRight,
- nBottom,
- nTAspect,
- nTSize;
-
- XY xyMin,
- xyMax,
- xyExtents,
- xyPt,
- xyStartPt,
- xyTemp,
- xyStartLine,
- xyEndLine;
-
- procedure pnTableHeader()
- // %1 = xyStartPoint.x of table
- // %2 = xyStartPoint.y of table
- // %3 = text aspect
- // %4 = text size
- {
- // assign proc vars
- xyPt.x = %1;
- xyPt.y = %2;
- nTA = %3;
- nTS = %4;
-
- xyPt.y = xyPt.y + (2 * nTS);
- // create the top line of the title
- StartPoly("polyline");
- AddVertex(xyPt.x - (1 * nTA), xyPt.y - (.65 * nTS));
- AddVertex(xyPt.x - (1 * nTA), xyPt.y + (1.35 * nTS));
- AddVertex(xyPt.x + (93 * nTA), xyPt.y + (1.35 * nTS));
- AddVertex(xyPt.x + (93 * nTA), xyPt.y - (.65 * nTS));
- EndPoly();
-
- // add the column titles
- AddEntity("text", "ITEM", xyPt);
- xyPt.x = xyPt.x + nTAspect * 7;
- AddEntity("text", "PART NO.", xyPt);
- xyPt.x = xyPt.x + nTAspect * 18;
- AddEntity("text", "QUAN.", xyPt);
- xyPt.x = xyPt.x + nTAspect * 9;
- AddEntity("text", "DESCRIPTION", xyPt);
- }
-
- // add a new layer
- Table("add", "layer", "List", "Symbol List", "current",
- Table("find", "color", "red"));
-
- // make the new layer current
- Execute("menu", "SetLayer", Table("find", "layer", "List"));
- Execute("menu", "SetColor", Table("find", "color", "red"));
- Execute("menu", "SetStyle", Table("find", "style", "solid"));
-
- // get some necessary information
- GetData("drawingscale", &nDrawingScale);
- GetData("textheight", &nTextHeight);
- GetData("TextAspect", &nTAspect);
- GetUser("xy", "Pick UPPER RIGHT corner of list", &xyStartPt);
-
- // convert sheet sizes to world sizes
- nSize = 1/nDrawingScale;
- nTAspect = nTextHeight * nTAspect * nSize;
- nTSize = nTextHeight * nSize;
-
- // define starting point for list
- xyStartPt.x = xyStartPt.x - (93 * nTAspect);
- xyStartPt.y = xyStartPt.y - (nTSize * 1.40);
-
- // procedure to build the header for the table
- pnTableHeader(xyStartPt.x, xyStartPt.y, nTAspect, nTSize);
-
- // procedure TableHeader borrows this variable name
- // we need to reset it now
- xyPt = xyStartPt;
-
- // initilize the counter
- nCount = 1;
-
- // open a symbol list, helps isolate symbols
- hSymList = Open("symlist", "*");
- while(GetNextSymbol(hSymList, &sSymbol))
- {
-
- // create a DQL expression, and open a selection set
- sDQLExpression = "DB SymbolName = '" + sSymbol + "'";
- hSel = Open("selection", sDQLExpression);
- if(!(hSel))
- Exit(%abort, "UNABLE TO OPEN SELECTION SET!!");
-
- ResetSelection(hSel);
- while(hEnt = GetNextSelection(hSel))
- {
- // get necessary data, check if it's valid
- GetDBData(hEnt, "SymbolDesc", &sSymbolDesc);
- if(StringCompare(sSymbolDesc, ""))
- {
- bDesc = %false;
- break;
- }
-
- // used later to determine if a valid description is present
- bDesc = %true;
-
- GetDBData(hEnt, "SymbolType", &sSymbolType);
- if(StringCompare(sSymbolType, ""))
- {
- bType = %false;
- break;
- }
-
- // used later to determine if a valid type is present
- bType = %true;
-
- // put number in circle on drawing
- if((bType == %true) && (bDesc == %true))
- {
- // calculate symbol extents
- GetExtent(hEnt, &xyMin, &xyMax);
- xyExtents.x = xyMax.x - xyMin.x;
- xyExtents.y = xyMax.y - xyMin.y;
- xyPt.x = (xyExtents.x * .5) + xyMin.x;
- xyPt.y = (xyExtents.y * .5) + xyMin.y;
-
- // set text justification for symbol labeler
- SetData("TextHorzJust", 2);
- SetData("TextVertJust", 16);
-
- // add the text
- AddEntity("text", MakeString("scalar", nCount), xyPt);
-
- // add the circle
- AddEntity("circle", xyPt, nTSize * 1.5);
-
- // number of each symbol type
- nSymCount = nSymCount + 1;
- }
- }
- // and close the selection set
- Close("selection", hSel);
-
- // reset the justification
- SetData("TextHorzJust", 1);
- SetData("TextVertJust", 32);
- if((bType == %true) && (bDesc == %true))
- {
- // draw lines from left, across the top and down the right side
- // of each entry in the table
- StartPoly("polyline");
- AddVertex(xyStartPt.x - (1 * nTAspect), xyStartPt.y - (.65 * nTSize));
- AddVertex(xyStartPt.x - (1 * nTAspect), xyStartPt.y + (1.35 * nTSize));
- AddVertex(xyStartPt.x + (93 * nTAspect), xyStartPt.y + (1.35 * nTSize));
- AddVertex(xyStartPt.x + (93 * nTAspect), xyStartPt.y - (.65 * nTSize));
- EndPoly();
-
- xyPt = xyStartPt;
- xyPt.x = xyPt.x + nTAspect * 1;
- AddEntity("text", MakeString("scalar", nCount), xyPt);
- xyPt.x = xyPt.x + nTAspect * 6;
- AddEntity("text", sSymbolType, xyPt);
- xyPt.x = xyPt.x + nTAspect * 19;
- AddEntity("text", MakeString("scalar", nSymCount), xyPt);
- xyPt.x = xyPt.x + nTAspect * 8;
- AddEntity("text", sSymbolDesc, xyPt);
- xyStartPt.y = xyPt.y - (2 * nTSize);
-
- // increment the counter
- nCount = nCount + 1;
-
- }
-
- // reset the symbol type counter
- nSymCount = 0;
- }
- // reset the text justification
- SetData("TextHorzJust", 1);
- SetData("TextVertJust", 32);
-
- // calculate the position and size of the last line (bottom of the chart)
- xyStartLine.x = xyStartPt.x - (1 * nTAspect);
- xyStartLine.y = xyStartPt.y + (nTSize * 1.35);
- xyEndLine.x = xyStartLine.x + (94 * nTAspect);
- xyEndLine.y = xyStartLine.y;
- AddEntity("line", xyStartLine, xyEndLine);
-
- Exit(%ok, "");
- // [eof] list.d
-